@extends('layouts.base')

@section('title', '角色')



@section('content')

<!-- ============================================================== -->
<!-- Container fluid  -->
<!-- ============================================================== -->
<div class="container-fluid">
	<!-- ============================================================== -->
	<!-- Bread crumb and right sidebar toggle -->
	<!-- ============================================================== -->
	<div class="row page-titles">
	    <div class="col-md-5 align-self-center">
	        <h3 class="text-themecolor">角色--列表</h3>
	    </div>
	    <div class="col-md-7 align-self-center">
	        <ol class="breadcrumb">
	            <li class="breadcrumb-item"><a href="javascript:void(0)">首页</a></li>
	            <li class="breadcrumb-item">角色管理</li>
	            <li class="breadcrumb-item active">角色列表</li>
	        </ol>
	    </div>
	</div>
	<!-- ============================================================== -->
	<!-- End Bread crumb and right sidebar toggle -->
	<!-- ============================================================== -->

	<!-- ============================================================== -->
	<!-- Start Page Content -->
	<!-- ============================================================== -->
	<div class="row">
	    <div class="col-12">
	        <div class="card">
	            <div class="card-body">
	                <h4 class="card-title">管理列表</h4>
	                <h6 class="card-subtitle"></h6>
                	<div class="card-body">
                        <form method="get" action="{{ route('admin.roles.index') }}">
                            <div class="form-row">
                                <div class="col-md-3 mb-3">
                                  <label for="validationDefault04">名称: </label>
                                  <input type="text" name="name" class="form-control" id="validationDefault04" placeholder="姓名" value="{{ $name }}" >
                                </div>
                            </div>
                            <button class="btn btn-primary" type="submit">筛选</button>
                            <a href="{{ route('admin.roles.index') }}" class="btn btn-info">重置</a>
                        </form>
                        <a class="btn btn-success float-right" href="{{ route('admin.roles.create') }}"><i class="fas fa-plus"></i> 添加</a>       
                    </div>        
	                <div class="table-responsive">
	                    <table id="demo-foo-addrow" class="table table-bordered m-t-30 table-hover contact-list" data-paging="true" data-paging-size="7">
	                        <thead>
	                            <tr>
	                                <th>ID</th>
	                                <th>名称</th>                             
	                                <th>创建时间</th>
	                                <th>操作</th>
	                            </tr>
	                        </thead>
	                        <tbody>
	                        	@foreach($roles as $value)
	                            <tr>
	                                <td>{{ $value['id'] }}</td>
	                                <td>{{ $value['name'] }}</td>
	                                <td>{{ $value['created_at'] }}</td>
	                                <td>{!! $value['actionButton'] !!}</td>
	                            </tr>	                                                     
	                            @endforeach
	                        </tbody>
	                    </table>
	                    {{ $roles->appends(['name' => $name])->links() }}
	                </div>
	            </div>
	        </div>
	    </div>
	</div>
</div>         
                        
@stop

@section('admin-js')
	<script type="text/javascript">		

		function del(){
			swal({
			  title: "您确定要删除吗?",
			  icon: "warning",
			  buttons: ['取消', '确定'],
			  dangerMode: true,
			})
			.then((willDelete) => {
			  if (willDelete) {			    
			    $('#deleteForm').submit();
			  } else {
			    
			  }
			});
			
		}
		
	</script>

@stop